package service;

import java.util.List;

import util.RegexUtil;
import dao.ActorDAO;
import dao.ActorJobDAO;
import dao.CrewJobDAO;
import dao.UserDAO;
import domain.Actor;
import domain.ActorJob;
import domain.CrewJob;
import domain.Movie;
import domain.User;
import ex.AuthenticationFailedException;
import ex.DatabaseException;
import ex.ProjectCompositionFailedException;
import ex.RegistrationFailedException;

public class JobService {

	ActorJobDAO actorJobDao=new ActorJobDAO();
	CrewJobDAO crewJobDao=new CrewJobDAO();
	
	public void createActorJob(ActorJob actorJob) throws  DatabaseException, ProjectCompositionFailedException{
		if(actorJob!=null){
			actorJobDao.insertActorJob(actorJob);
		}
		else{
			throw new ProjectCompositionFailedException("Project composition succeded but actor definition is not. Please add it later on! ");
		}		
	}
	
	public void createCrewJob(CrewJob crewJob) throws  DatabaseException, ProjectCompositionFailedException{
		if(crewJob!=null){
			crewJobDao.insertCrewJob(crewJob);
		}
		else{
			throw new ProjectCompositionFailedException("Project composition succeded but crew definition is not. Please add it later on! ");
		}		
	}
	
	public List<ActorJob> getActorJobsByMovie(Movie movie) throws  DatabaseException, ProjectCompositionFailedException{
		if(movie!=null){
			return  actorJobDao.selectActorJobByMid(movie.getMid());
		}
		else{
			throw new ProjectCompositionFailedException("Project composition succeded but actor definition is not. Please add it later on! ");
		}		
	}
	
	public List<CrewJob> getCrewJobsByMovie(Movie movie) throws  DatabaseException, ProjectCompositionFailedException{
		if(movie!=null){
			return  crewJobDao.selectCrewJobByMid(movie.getMid());
		}
		else{
			throw new ProjectCompositionFailedException("Project composition succeded but actor definition is not. Please add it later on! ");
		}		
	}

}
